<?php
/**
 * Created by PhpStorm.
 * User: 徐州
 * Date: 2017/5/24
 * Time: 15:38
 */

namespace App\Models\Resource;

class ResourceRepository implements \App\Contracts\Repositories\ResourceRepository
{
    public function update($candidateID, $resourceID, $resourceUrl)
    {
        return Resource::where(['candidate_id' => $candidateID, 'resource_id' => $resourceID])
            ->update(['resource_url' => $resourceUrl]);
    }

    public function create($resource)
    {
        if (empty($resource)) {
            return [];
        }
        $existResource = Resource::where($resource)->first();
        if ($existResource) {
            return $existResource;
        }
        return Resource::create($resource);
    }
}
